<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@taglib prefix="form"  uri="http://www.springframework.org/tags/form"%> 
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>新增用户</title>

<script src="${pageContext.request.contextPath}/static/lib/jquery-1.11.1.min.js"  type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/static/lib/jquery.metadata.js"  type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/static/lib/jquery.validate.min.js"  type="text/javascript"></script>
</head>

<body>
	<form:form id="userForm"  action="add" method="post" modelAttribute="user">
	
<!--  	使用jQuery验证  ，客户端	
		<table align="center">
			<tr><td colspan="2"><h2 align="center">添加</h2></td></tr>
			<tr>
				<td>ID</td>
				<td><form:input path="id" cssClass="{required:true,min:1,max:180,digits:true}"/></td>
			</tr>
			<tr>
				<td>姓名</td>
				<td><form:input path="name" cssClass="{required:true,maxlength:15}"/></td>
			</tr>
			<tr>
				<td>年龄</td>
				<td><form:input path="age" cssClass="{required:false,min:1,max:250,digits:true}"/></td>
			</tr>
			<tr><td colspan="2"><button type="submit">提交</button></td></tr>
		</table>	
-->		

<!-- 使用JSR303验证   服务端 -->		
		<table align="center">
			<tr><td colspan="2"><h2 align="center">添加</h2></td></tr>
			<tr>
				<td>ID</td>
				<td><form:input path="id" /><form:errors path="id" cssClass="error" cssStyle="color:red;"/></td>
			</tr>
			<tr>
				<td>姓名</td>
				<td><form:input path="name" /><form:errors path="name" cssClass="error" cssStyle="color:red;"/></td>
			</tr>
			<tr>
				<td>年龄</td>
				<td><form:input path="age" /><form:errors path="age" cssClass="error" cssStyle="color:red;"/></td>
			</tr>
			<tr><td colspan="2"><button type="submit">提交</button></td></tr>
		</table>
		
		
	</form:form>
	<script type="text/javascript">
		$().ready(function(){			
			$("#userForm").validate();
		});
	</script>
	
</body>
</html>